package com.hrsoft.edi.stub;

import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import com.hrsoft.edi.stub.consant.AppInfo;
import com.hrsoft.edi.stub.request.SingleitemSynchronizeRequest;
import com.qimen.api.DefaultQimenClient;
import com.qimen.api.QimenClient;
import com.qimen.api.response.SingleitemSynchronizeResponse;
import com.taobao.api.ApiException;
import org.apache.commons.lang3.StringUtils;

public class SingleItemTest
{
    public static void main(String[] args)
    {
        create("0001","0001","0001");
    }

    public static void create(String itemCode,String itemName,String barcode)
    {
        SingleitemSynchronizeRequest singleitemSynchronizeRequest = new SingleitemSynchronizeRequest();
        singleitemSynchronizeRequest.setCustomerId(AppInfo.CUSTOMER_ID);
        singleitemSynchronizeRequest.setWarehouseCode("OTHER");
        singleitemSynchronizeRequest.setActionType("ADD");
        SingleitemSynchronizeRequest.Item item = new SingleitemSynchronizeRequest.Item();
        item.setItemCode(itemCode);
        item.setItemName(itemName);
        item.setBarCode(barcode);
        item.setStockUnit("个");
        item.setItemType("ZP");
//        item.setWarehouseCode("123");
//        item.setCategoryName("测试");
        singleitemSynchronizeRequest.setItem(item);
        singleitemSynchronizeRequest.setOwnerCode(AppInfo.OWNER_CODE);
        QimenClient client = new DefaultQimenClient(AppInfo.URL, AppInfo.APP_KEY, AppInfo.SECRET);
        try
        {
            SingleitemSynchronizeResponse response = client.execute(singleitemSynchronizeRequest);
            System.out.println(new JSONObject(response));
        }
        catch (ApiException e)
        {
            e.printStackTrace();
        }
    }
}
